class CreateInfoTypes < ActiveRecord::Migration
  def self.up
    create_table :info_types do |t|
      t.string :code,
        :name
      t.integer :infos_count, :default => 0
      t.timestamps
    end
    add_column :infos, :info_type_id, :integer, :default => 1
    if not Rails.env.test?
      InfoType.create! :code => 'common',
        :name => '普通'
      InfoType.create! :code => 'gift',
        :name => '礼包'
      InfoType.create! :code => 'weather_alert',
        :name => '天气预警'
    end    
    
  end

  def self.down
    drop_table :info_types
    remove_column :infos, :info_type_id
  end
end
